Skip to content

fix(runtime): use Weak to break reference cycle#490

Merged
Berrysoft merged 1 commit into
compio-rs:masterfrom
Paraworker:fix/ref-cycle
Oct 19, 2025
Merged

fix(runtime): use Weak to break reference cycle#490
Berrysoft merged 1 commit into
compio-rs:masterfrom
Paraworker:fix/ref-cycle

Conversation

@Paraworker
Copy link
Copy Markdown
Contributor

Fixes #489

This comment was marked as resolved.

Copy link
Copy Markdown
Member

@Berrysoft Berrysoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Berrysoft
Copy link
Copy Markdown
Member

Thanks anyways. I have considered weak refs, but didn't use it because of performance considerations. Now it seems necessary so...

@Berrysoft Berrysoft merged commit 4a5c750 into compio-rs:master Oct 19, 2025
49 checks passed
@Paraworker Paraworker deleted the fix/ref-cycle branch October 19, 2025 13:00
}
}

impl Drop for Runtime {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, no. This change may make the runtime panic on drop. The runnables should be dropped in self.enter, or they cannot find the right runtime to cancel the time futures.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I recently discovered that if a Waker is dropped in another thread and the Weak upgrade fails inside schedule, the Runnable end up being dropped in that other thread. I’m currently looking into how async-executor implements this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to forget the runnable in that case...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory leak when dropping waker after runtime drop

3 participants